
public class ChainedCounterModel extends CounterModel {

	private CounterInterface next;
	private int init;
	
	public ChainedCounterModel(int time, int m, CounterInterface c) {
		super(m);
		this.init = time;
		next = c;
	}

	@Override
	public void increment() {	
		init++;
		init %= super.getModulus();
		if(init==0 && next!=null){
			next.increment();
		}
	}
	
	@Override
	public int getCounter(){
		return init;
	}
}

